﻿@inherits RolesBase

<EditPage @ref="EditPage" Id="role" FixedHeader="@FixedHeader" TItem="Bootstrap.DataAccess.Role" SubmitModalTitle="角色编辑窗口" QueryModel="QueryModel" OnQuery="Query" OnAdd="Add" OnDelete="Delete" OnSave="Save" OnResetSearch="ResetSearch">
    <QueryBody>
        <LgbInputText ColumnClass="col-sm-auto" @bind-Value="@context.RoleName" maxlength="50" />
        <LgbInputText ColumnClass="col-sm-auto" @bind-Value="@context.Description" maxlength="50" />
    </QueryBody>
    <TableToolbarTemplate>
        <TableToolbarButton class="btn btn-info" Icon="fa fa-user" Title="分配用户" OnClick="AssignUsers" />
        <TableToolbarButton class="btn btn-warning" Icon="fa fa-bank" Title="分配部门" OnClick="AssignGroups" />
        <TableToolbarButton class="btn btn-secondary" Icon="fa fa-dashboard" Title="分配菜单" OnClick="AssignMenus" />
        <TableToolbarButton class="btn btn-success" Icon="fa fa-cubes" Title="分配应用" OnClick="AssignApps" />
    </TableToolbarTemplate>
    <TableInfoTemplate>
        <div class="alert alert-info" role="alert">
            <span>禁止修改系统内置 Administrators Default 两个角色</span>
        </div>
    </TableInfoTemplate>
    <TableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.RoleName" Sort="true"></LgbTableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.Description" Sort="true"></LgbTableHeader>
    </TableHeader>
    <RowTemplate>
        <td>@context.RoleName</td>
        <td>@context.Description</td>
    </RowTemplate>
    <EditTemplate>
        <div class="row">
            <LgbInputText @bind-Value="@context.RoleName" placeholder="不可为空，50字以内" maxlength="50">
                <RequiredValidator />
                <StringLengthValidator Length="50" />
            </LgbInputText>
            <LgbInputText @bind-Value="@context.Description" placeholder="不可为空，500字以内" maxlength="500">
                <RequiredValidator />
                <StringLengthValidator Length="500" />
            </LgbInputText>
        </div>
    </EditTemplate>
</EditPage>

<AssignModal @ref="AssignUserModal" TItem="Bootstrap.DataAccess.User" Id="role-user" Title="用户授权窗口" OnSave="SaveUsers">
    <ItemTemplate>
        <Checkbox TItem="Bootstrap.DataAccess.User" Item="@context" Text="@context.FormatDisplayName()" SetCheckCallback="SetUserCheck" OnClick="OnUserClick" />
    </ItemTemplate>
</AssignModal>

<AssignModal @ref="AssignGroupModal" TItem="Bootstrap.DataAccess.Group" Id="role-group" Title="部门授权窗口" OnSave="SaveGroups">
    <ItemTemplate>
        <Checkbox TItem="Bootstrap.DataAccess.Group" Item="@context" Text="@context.GroupName" SetCheckCallback="SetGroupCheck" OnClick="OnGroupClick" />
    </ItemTemplate>
</AssignModal>

<AssignModal @ref="AssignAppModal" TItem="Bootstrap.DataAccess.App" Id="role-app" Title="应用授权窗口" OnSave="SaveApps">
    <ItemTemplate>
        <Checkbox TItem="Bootstrap.DataAccess.App" Item="@context" Text="@context.AppName" SetCheckCallback="SetAppCheck" OnClick="OnAppClick" />
    </ItemTemplate>
</AssignModal>
